home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
vdl020d.zip
/
VUART.DOC
< prev
next >
Wrap
Text File
|
1993-04-14
|
22KB
|
825 lines
{
════════════════════════════════════════════════════════════════════════════
Visionix Serial Communictions Unit - 8250 specification (VUART)
Version 0.1
Copyright 1991,92,93 Visionix
ALL RIGHTS RESERVED
────────────────────────────────────────────────────────────────────────────
** revision history in reverse chronological order **
Initials Date Comment
──────── ──────── ────────────────────────────────────────────────────────
lpg 03/16/93 Added Source Documentation
mep 02/11/93 Cleaned up code for beta release
jrt 11/21/92 Sync with beta 0.08
mep 11/11/92 First logged revision.
────────────────────────────────────────────────────────────────────────────
}
Unit VUART;
Uses
DOS,
VBios,
VTypes,
VSerLow;
{────────────────────────────────────────────────────────────────────────────}
Const
TxMaxBuffSize : WORD = 16;
RxMaxBuffSize : WORD = 16;
VUARTDriverInterval : BYTE = 4; { number of internal loops until IRET }
Type
AChar = Array[1..1] of CHAR;
PChar = ^AChar;
TUARTBuff = RECORD
Buff : PChar; { Queue }
Head : WORD; { Store next character }
Tail : WORD; { Retrieve next character }
NumIn : LONGINT; { Number of characters in Buff }
END;
PUARTBuff = ^TUARTBuff;
{----}
TUARTIData = RECORD
ComPort : BYTE; { Communications port }
BaudRate : LONGINT; { Bits per second rate }
Parity : CHAR; { Parity of hardware error checking }
DataBits : BYTE; { Number of data bits }
StopBits : BYTE; { Number of stop bits }
PortStat : WORD; { Condition of UART (MCR/LSR) }
Bit : BYTE; { Bit to check PortStat with }
Sig : WORD; { $1954 if UART-info installed }
MaxFunc : BYTE; { Max function number supported }
UARTRev : BYTE; { Revision of VUART Driver specification }
TickNum : BYTE; { Timer tick interrupt number }
TickPSec : BYTE; { Approximate interrupts per sec. (18 on IBM) }
MilPTick : WORD; { Approximate number of milliseconds per tick }
ChAvail : BOOLEAN; { Is a character waiting in receive buffer? }
BuffFull : BOOLEAN; { Is the buffer in hand full? }
BuffEmpty : BOOLEAN; { Is the buffer in hand empty? }
ScanCode : WORD; { Scancode from local kbd ($FFFF if empty) }
CtrlStat : BYTE; { Control-key bitfield for Ctrl-C/Ctrl-K }
CtrlRcv : BOOLEAN; { a Ctrl-C or Ctrl-K has been received }
WarmBoot : BOOLEAN; { Warmboot the system. Otherwise, coldboot }
Buff : POINTER; { Block Read/Write Buffer Pointer }
Count : WORD; { Number of bytes to transfer of Buff. }
Result : WORD; { Number of bytes of Buff actually transfered }
CtrlReg : BYTE; { Condition of MCR (for get/set) }
BuffSize : WORD; { Size of Buff (in bytes) }
Ch : CHAR; { Generic Character (I/O) }
OnOff : BOOLEAN; { Generic parameter for On/Off (True/False) }
X : BYTE; { Generic X-coordinate }
Y : BYTE; { Generic Y-coordinate }
IRQ : WORD; { current IRQ [4, 3] }
Intrpt : WORD; { current Intrpt [$C, $B] }
OldIER : BYTE;
OldMCR : BYTE;
OldVect : POINTER;
OldICMask : BYTE;
{ RxBuff : TComBuff;
TxBuff : TComBuff; }
END;
PUARTIData = ^TUARTIData;
{────────────────────────────────────────────────────────────────────────────}
Procedure VUARTSetCommParam( ComPort : LONGINT;
BaudRate : WORD;
Parity : CHAR;
DataBits : BYTE;
StopBits : BYTE;
Var PortStat : WORD;
IData : PUARTIData);
Procedure VUARTSendCharW( ComPort : WORD;
Ch : CHAR;
Var PortStat : WORD;
IData : PUARTIData);
Procedure VUARTRecvCharW( ComPort : WORD;
Var Ch : CHAR;
Var PortStat : WORD;
IData : PUARTIData);
Function VUARTGetChar( ComPort : WORD ) : CHAR;
Procedure VUARTGetPortStat( ComPort : WORD;
Var PortStat : WORD;
IData : PUARTIData);
Function VUARTChkPortStat( ComPort : WORD;
Bit : BYTE;
IData : PUARTIData) : BOOLEAN;
Procedure VUARTActivatePort( ComPort : WORD;
Var Sig : WORD;
Var MaxFunc : BYTE;
Var FosRev : BYTE;
IData : PUARTIData);
Procedure VUARTDeActivatePort( ComPort : WORD;
IData : PUARTIData);
Procedure VUARTSetDTR( ComPort : WORD;
OnOff : BOOLEAN;
IData : PUARTIData);
Procedure VUARTGetTimeTickInfo( Var TickNum : BYTE;
Var TickPSec : BYTE;
Var MilPTick : WORD );
Procedure VUARTFlushOutBuff( ComPort : WORD );
Procedure VUARTPurgeOutBuff( ComPort : WORD;
IData : PUARTIData);
Procedure VUARTPurgeInBuff( ComPort : WORD;
IData : PUARTIData);
Procedure VUARTSendChar( ComPort : WORD;
Ch : CHAR;
Var BuffFull : BOOLEAN;
IData : PUARTIData);
Procedure VUARTRecvChar( ComPort : WORD;
Var Ch : CHAR;
Var BuffEmpty : BOOLEAN;
IData : PUARTIData);
Procedure VUARTPeekAhead( ComPort : WORD;
Var BuffEmpty : BOOLEAN;
Var Ch : CHAR );
Procedure VUARTSetFlowControl( ComPort : WORD;
FlowStat : BYTE );
Procedure VUARTControlCheck( ComPort : WORD;
CtrlStat : BYTE;
Var CtrlRcv : BOOLEAN );
Procedure VUARTRecvBlock( ComPort : WORD;
Buff : POINTER;
Count : WORD;
Var Result : WORD );
Procedure VUARTSendBlock( ComPort : WORD;
Buff : POINTER;
Count : WORD;
Var Result : WORD );
Procedure VUARTSetBreak( ComPort : WORD;
OnOff : BOOLEAN );
{────────────────────────────────────────────────────────────────────────────}
Procedure UARTSerDriverProc( SDP : PSerDriverPacket );
{────────────────────────────────────────────────────────────────────────────}
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTSetCommParam( ComPort : LONGINT;
BaudRate : WORD;
Parity : CHAR;
DataBits : BYTE;
StopBits : BYTE;
Var PortStat : WORD;
IData : PUARTIData);
[PARAMETERS]
ComPort Communications Port Number
BuadRate Desired Baud Rate for Port
Parity Desired Parity for Port
DataBits Desired Number of Data Bits for Port
StopBits Desired Number of Stop Bits for Port
PortStat VAR Returned ?
IData Pointer to UART IData Structure
[RETURNS]
[DESCRIPTION]
{----------------------------------------------------------------------------}
{ }
{ Function 00h - Set communications parameters, baud, parity etc. }
{ }
{ The IBM PC BIOS call to set modem status. }
{ }
{ INPUT: ComPort, BaudRate, Parity, DataBits, StopBits }
{ }
{ OUTPUT: PortStat }
{ }
{----------------------------------------------------------------------------}
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTSendCharW( ComPort : WORD;
Ch : CHAR;
Var PortStat : WORD;
IData : PUARTIData);
[PARAMETERS]
ComPort Communications Port Number
Ch Charcter to Send
PortStat VAR Returned ?
IData Pointer to UART IData Structure
[RETURNS]
Function : None
(VAR : [PortStat] ?)
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTRecvCharW( ComPort : WORD;
Var Ch : CHAR;
Var PortStat : WORD;
IData : PUARTIData);
[PARAMETERS]
ComPort Communications Port Number
Ch VAR Returned ?
PortStat VAR Returned ?
IData Pointer to UART IData Structure
[RETURNS]
Function : None
(VAR : [Ch] ?)
(VAR : [PortStat] ?)
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function VUARTGetChar( ComPort : WORD ) : CHAR;
[PARAMETERS]
ComPort Communications Port Number
[RETURNS]
Character Read from that Comm Port
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTGetPortStat( ComPort : WORD;
Var PortStat : WORD;
IData : PUARTIData);
[PARAMETERS]
ComPort Communications Port Number
PortStat VAR Returned ?
IData Pointer to UART IData Structure
[RETURNS]
(None)
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function VUARTChkPortStat( ComPort : WORD;
Bit : BYTE;
IData : PUARTIData) : BOOLEAN;
[PARAMETERS]
ComPort Communications Port Number
Bit ?
IData Pointer to UART IData Structure
[RETURNS]
Whether the ...
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTActivatePort( ComPort : WORD;
Var Sig : WORD;
Var MaxFunc : BYTE;
Var FosRev : BYTE;
IData : PUARTIData);
[PARAMETERS]
ComPort Communications Port Number
Sig VAR Returned ?
MaxFunc VAR Returned ?
FosRev VAR Returned ?
IData Pointer to UART IData Structure
[RETURNS]
Function : None
(VAR : [MaxFunc]
(VAR : [FosRev]
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTDeActivatePort( ComPort : WORD;
IData : PUARTIData);
[PARAMETERS]
ComPort Communications Port Number
IData Pointer to UART IData Structure
[RETURNS]
(None)
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTSetDTR( ComPort : WORD;
OnOff : BOOLEAN;
IData : PUARTIData);
[PARAMETERS]
ComPort Communications Port Number
OnOff Whether to Set the ... (TRUE=On)
IData Pointer to UART IData Structure
[RETURNS]
(None)
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTGetTimeTickInfo( Var TickNum : BYTE;
Var TickPSec : BYTE;
Var MilPTick : WORD );
[PARAMETERS]
TickNum VAR Returned Current Number of Clock Ticks
TickPSec VAR Returned Number of Ticks Per Second
MilPTick VAR Returned ?
[RETURNS]
Function : None
(VAR : [TickNum] Current Number of Clock Ticks)
(VAR : [TickPSec] Number of Ticks Per Second)
(VAR : [MilPTick] ?)
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTFlushOutBuff( ComPort : WORD );
[PARAMETERS]
ComPort Communications Port Number
[RETURNS]
(None)
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTPurgeOutBuff( ComPort : WORD;
IData : PUARTIData);
[PARAMETERS]
ComPort Communications Port Number
IData Pointer to UART IData Structure
[RETURNS]
(None)
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTPurgeInBuff( ComPort : WORD;
IData : PUARTIData);
[PARAMETERS]
ComPort Communications Port Number
IData Pointer to UART IData Structure
[RETURNS]
(None)
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTSendChar( ComPort : WORD;
Ch : CHAR;
Var BuffFull : BOOLEAN;
IData : PUARTIData);
[PARAMETERS]
ComPort Communications Port Number
Ch Character to Send
BuffFull VAR Returned Whether Receiver's Buffer is Full (TRUE=Full)
IData Pointer to UART IData Structure
[RETURNS]
Function : None
(VAR : [BuffFull] Whether Receiver's Buffer is Full)
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTRecvChar( ComPort : WORD;
Var Ch : CHAR;
Var BuffEmpty : BOOLEAN;
IData : PUARTIData);
[PARAMETERS]
ComPort Communications Port Number
Ch VAR Returned Character...
BuffEmpty VAR Returned Whether Receive Buffer is Empty (TRUE=Empty)
IData Pointer to UART IData Structure
[RETURNS]
Function : None
(VAR : [Ch] Character...
(VAR : [BuffEmpty] Whether Reveive Buffer is Empty)
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTPeekAhead( ComPort : WORD;
Var BuffEmpty : BOOLEAN;
Var Ch : CHAR );
[PARAMETERS]
ComPort Communications Port Number
BuffEmpty VAR Returned Whether In Buffer is Empty
Ch VAR Returned Next Available Character in Buffer
[RETURNS]
Function : None
(VAR : [BuffEmpty] Whether In Buffer is Empty)
(VAR : [Ch] Next Available Character in Buffer)
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTSetFlowControl( ComPort : WORD;
FlowStat : BYTE );
[PARAMETERS]
ComPort Communications Port Number
FlowStat ?
[RETURNS]
(None)
[DESCRIPTION]
ComPort,
FlowStat Bit 0 = 1 Enable receiving of Xon/Xoff. This will stop
transmitting when Xoff is received.
Bit 1 = 1 Enable RTS/CTS flow control. This will drop RTS
when receive buffer is 3/4 full and will be
raised when buffer is emptied to 1/4 full. If
the baud rate is locked, then RTS/CTS will be
forced. NOT IMPLEMENTED YET.
Bit 2 = 0 Reserved. Should always be 0.
Bit 3 = 1 Enable transmitting of Xon/Xoff. This will
send an Xoff when the buffers are 3/4 full, and
will send an Xon when they return to 1/4 full.
Reserved. ISR uses.
Bit 4 = 1 XOFF is currently set. Do not transmit.
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTControlCheck( ComPort : WORD;
CtrlStat : BYTE;
Var CtrlRcv : BOOLEAN );
[PARAMETERS]
ComPort Communications Port Number
CtrlStat ?
CtrlRcv VAR Returned ?
[RETURNS]
Function : None
(VAR : [CtrlRcv] ?)
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTRecvBlock( ComPort : WORD;
Buff : POINTER;
Count : WORD;
Var Result : WORD );
[PARAMETERS]
ComPort Communications Port Number
Buff Pointer to Data Buffer to Receive
Count Maximum Number of Bytes to Receive
Result VAR Returned Error Code (0=Success)
[RETURNS]
Function : None
(VAR : [Result] Error Code)
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTSendBlock( ComPort : WORD;
Buff : POINTER;
Count : WORD;
Var Result : WORD );
[PARAMETERS]
ComPort Communications Port Number
Buff Pointer to Data Buffer to Send
Count Number of Bytes in Buffer
Result VAR Returned Error Code (0=Success)
[RETURNS]
Function : None
(VAR : [Result] Error Code)
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure VUARTSetBreak( ComPort : WORD;
OnOff : BOOLEAN );
[PARAMETERS]
ComPort Communications Port Number
OnOff Active Status (TRUE=On)
[RETURNS]
(None)
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure UARTSerDriverProc( SDP : PSerDriverPacket );
[PARAMETERS]
SDP Pointer to Serial Driver Packet
[RETURNS]
(None)
[DESCRIPTION]
[SEE-ALSO]
[EXAMPLE]